// zh_jypx/pages/teacher/t_statue.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: 0,
    level:[
      {"id":"1","con":"待批改"},
      { "id": "3", "con": "待修订"}
    ],
    s_index:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var class_id = options.class_id
    console.log(options)
    var that=this;
    that.setData({
      class_id: class_id
    })

    // —————————————— 获取网址——————————
    app.util.request({
      "url": "entry/wxapp/Attachurl",
      'cachetime': '0',
      success: function (res) {
        that.setData({
          url: res.data
        })
      }
    })

    that.order()
  },

  //获取列表数据
  order: function (e) {
    var that = this;
    console.log(that)
    var s_index = that.data.s_index
    console.log(s_index)
    var first_id = that.data.level[s_index].id
    var activeIndex = that.data.activeIndex
    var class_id = that.data.class_id
    console.log(first_id)
    //——————————————课程 ——————————
    app.util.request({
      'url': 'entry/wxapp/TaskList',
      'cachetime': '0',
      data: {
        status: first_id,
        class_id: class_id
      },
      success: function (res) {
        console.log("级别详情")
        console.log(res.data)
        if (res.data.code == 200) {
          that.setData({
            con: res.data.list,
            num:res.data.list.length
          })
          wx.setStorageSync('all_list', res.data.list)
        }
        that.setData({
          none: res.data
        })
      },
    })
  },

  /*点击课程选择 */
  onDetail: function (e) {
    var that = this;
    console.log(e)
    console.log(that.data)
    var detail_id = e.currentTarget.dataset.id
    var activeIndex = that.data.activeIndex;
    var s_index = e.currentTarget.dataset.index;
    var index = e.currentTarget.dataset.index;
    var class_id = that.data.class_id
    console.log(detail_id)
    that.setData({
      index: index,
      activeIndex: index,
      s_index: s_index
    })
    that.order()

  },

  /*进入详情 */
  t_class:function(e){
    var that=this;
    console.log(e)
    var task_id=e.currentTarget.dataset.id;
    console.log("当前列表的id:"+task_id)
    //用户的id
    var user_id = e.currentTarget.dataset.userid;
    console.log("用户的id:" +user_id)
    //当前的下标
    var index = e.currentTarget.dataset.index;
    console.log("当前下标:"+index)    
    //当前的下标
    var status = e.currentTarget.dataset.status;
    console.log("当前下标:" + status)

    wx:wx.navigateTo({
      url: 't_detail?task_id=' + task_id + "&userid=" + user_id + "&index=" + index + "&status=" + status ,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.order()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})